package com.zf.minio.config;

import jakarta.annotation.PostConstruct;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * minio配置
 */
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "minio")
// 配置文件中存在 "minio[endpoint, access-key, secret-key, default-bucket-name]" 属性时，才启用该配置
@ConditionalOnProperty(prefix = "minio", name = {"endpoint", "access-key", "secret-key", "default-bucket-name"})
public class MinioConfig {
    private String endpoint;
    private String accessKey;
    private String secretKey;
    private String defaultBucketName;

    /**
     * 配置minio客户端工具配置
     */
    @PostConstruct
    public void minioClientUtils() {
        MinioClientUtils.init(this);
    }
}
